<?php
use yii\helpers\Html;
use yii\helpers\Url;
//\frontend\assets\MktWapCommonAsset::register($this);

?>
<!--
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
-->

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="keywords" content="首页关键字" />
  <meta name="description" content="首页描述" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Cache-Control" content="no-cache" />
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=2.0" />
  <meta name="apple-mobile-web-app-capable" content="yes"/>
  
  <link rel="stylesheet" href="resources/css/weui/weui.min.css">
  <link rel="stylesheet" href="resources/css/main.min.css">
  
  <script src="resources/js/jquery-1.10.min.js"></script>
  <script src="resources/js/jquery.mousewheel.min.js"></script>
  <script src="resources/js/jquery.jscrollpane.min.js"></script>
  <script src="resources/js/scroll-startstop.events.jquery.min.js"></script>
  <title>意见反馈</title>
</head>
<body>

<div class="talk">
	<div class="talk_record">
		<div class="jp-container" id="jp-container">
<!--
			<div class="timeDiv"><div class="time">8月10日 早上10：20</div></div>
-->
            <?php foreach($feedbacks as $feedback): ?>
			<div class="talk_recordboxme">
				<div class="talk_recordtext_div">
					<div class="talk_recordtext">
                        <p><?php echo $feedback->content . ' [' . \common\wosotech\Util::timeago($feedback->create_time) . ']'; ?></p>
					</div>
				</div>
				<div class="user"><img src="<?= $me->headimgurl ?>"></div>
			</div>
            <?php endforeach; ?>			


			<div id="newMessage"></div>
		</div>
	
	</div>
	
	<div class="talk_word">
	<div class="talk_word_div">
		<div class="input_text"></div>
		<div class="inputdiv"><input id="inputMessage" class="messages emotion inputbox" autocomplete="off" value="在这里输入文字" onFocus="if(this.value=='在这里输入文字'){this.value='';}"  onblur="if(this.value==''){this.value='在这里输入文字';}"  /></div>
		<div onclick="addMessage()" class="talk_send"></div>
	</div></div>
</div>

<script type="text/javascript">

function addMessage()
{
	var obj = $("#newMessage");
	var msg = $("#inputMessage").val();
	$("#inputMessage").val('');
	var html = '<div class="talk_recordboxme">';
	html += '	<div class="talk_recordtext_div">';
	html += '		<div class="talk_recordtext">';
	html += '			<p>';
	html += msg;
	html += '			</p>';
	html += '		</div>';
	html += '	</div>';
	html += '	<div class="user"><img src="<?= $me->headimgurl ?>"/></div>';
	html += '</div>';
	obj.before(html);
    sendMessageAjax(msg);
}

function sendMessageAjax(msg) {
    var args = {
        'classname': '\\common\\models\\MktFeedback',
        'funcname': 'sendMessageAjax',
        'params': {
            'user_id': <?php echo $me->id; ?>,
            'content': msg
        }
    };

    $.ajax({
        url: "<?= Url::to(['/wap/ajax-broker']); ?>",
        type: "GET",
        cache: false,
        dataType: "json",
        data: "args=" + JSON.stringify(args),
        success: function (resp) {
            if (resp['code'] != 0) {
                alert("handle error");
                return;
            }
        },
        error: function () {
            //alert('send error');
        }
    });
}

</script>

</body>
</html>

<?php
/*
			<div class="talk_recordbox">
				<div class="user"><img src="<?= $me->headimgurl ?>"></div>
				<div class="talk_recordtext_div">
					<div class="talk_recordtext">
                        <p><?php echo $feedback->content . ' [' . \common\wosotech\Util::timeago($feedback->create_time) . ']'; ?></p>
					</div>
				</div>
			</div>

*/